package com.auth.sdk;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import java.util.Collections;
import java.util.List;

/**
 * Login info
 *
 * @description:  登录态权限数据
 * @author: cyj
 * @date 2021 -12-23 10:37:46
 *
 *
 */
@Data
@NoArgsConstructor
public class LoginInfo {

    private String userId;
    private String userName;
    private List<Object> roles;
    private List<Object> auths;

    public LoginInfo(String userId, String userName, List<Object> roles, List<Object> auths) {
        this.userId = userId;
        this.userName = userName;
        this.roles = null == roles ? Collections.EMPTY_LIST : roles;
        this.auths = null == auths ? Collections.EMPTY_LIST : auths;
//        if (StringUtils.isEmpty(userId)) {
//            // 匿名用户
//            this.userId = "unkown";
//            this.userName = "anonymous";
//            this.roles = null == roles ? Collections.EMPTY_LIST : roles;
//            this.auths = null == auths ? Collections.EMPTY_LIST : auths;
//        } else {
//            this.userId = userId;
//            this.userName = userName;
//            this.roles = null == roles ? Collections.EMPTY_LIST : roles;
//            this.auths = null == auths ? Collections.EMPTY_LIST : auths;
//        }
    }
}
